<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客编辑页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog-deit.css">
     
    <!--引入editor.md的依赖-->
    <link rel="stylesheet" href="editor.md//css/editormd.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>
</head>
<body>
    <!--导航栏-->
    <div class="nav">
         <img src="image/头像.jpg" alt="">
         <span class="title">ybo的博客系统</span>
         <!--spance用来占位-->
         <span class="spance"></span>
         <!--按钮-->
         <a href="blog_list.html">主页</a>
         <a href="blog_edit.html">写博客</a>
         <a href="javascript:logout()">注销</a>
    </div>
    <div class="blog-edit-container">
        
            <!--标题编辑区-->
            <div class="title">
                <input type="text" id="title" name="title" placeholder="请输入文章标题" name="title">
                <input type="button" id="submit" value="发布文章" onclick="mysub()">
            </div>
            <!--博客编辑标签-->
            <div id="editor" >
                <!-- 需要在这里加上一个隐藏的 textarea -->
                <!-- 属于 editor.md 这个库的需要 -->
                <textarea id="content" name="content" style="display: none;" ></textarea>
            </div>

       
    </div> 
    <script src="js/app.js"></script>


    <script>
        function mysub(){
            var title = jQuery("#title");
            var content = jQuery("#content");
            if(jQuery.trim(title.val())==""){
                alert("请输入标题");
                return false;
            }
            if(jQuery.trim(content.val())==""){
                alert("请输入内容");
                return false;
            }
            jQuery.ajax({
                url:"insert",
                tpye:"post",
                data:{
                    "title":title.val(),
                    "content":content.val()
                },
                success:function(result){
                    alert("恭喜发布成功！");
                    location.href = "blog_list.html";
                }
            });
        }
    </script>
    <script>
        // 注销
        function logout() {
        $.ajax({
            type: 'get',
            url: 'logout',
            success: function() {
                location.href = "blog_list.html"
            }
        });
}
    </script>
    <script>
        var editor = editormd("editor", {
            //这里尺寸必须在这里设置，设置样式会被editormd自动覆盖掉
            width: "100%",
            //设置编辑高度
            height: "calc(100% - 60px)",
            //编辑器中的初始内容
            markdown : "#在这里写一篇博客",
            path: "editor.md/lib/",
            // 加上这个属性，效果就是把编辑器里面的内容给自动的保存在 textarea 里
            saveHTMLToTextArea: true,

        });
    </script>


</body>
</html>